<?php 
require_once("../connect_db.php");
$sqlCourse="select * from course where status!='N'";
$queryCourse=mysql_query($sqlCourse);
?>

<form method="post" enctype="multipart/form-data" name="frmreg" id="frmreg">

<div class="row">
	<div class="col-md-12">
		<div class="panel">
		 
		  <div class="panel-body">
		  <div style="float:right;padding-bottom:20px;">
		  <button type="button" class="btn btn-success nav_link2" txt="เพิ่มข้อมูลคอร์ส" url="admin/insert_course_page.php"><span class="glyphicon glyphicon-plus" aria-hidden="true"></span>&nbsp;เพิ่มคอร์ส</button>
		
		  </div>
		  
			<table cellpadding="0" cellspacing="0" border="0" class="display" id="Course" width="100%" style="font-size:14px">
	<thead>
		<tr>
		
			<th style="width:40%;text-align: center !important;color:black; !important;font-size:1em">ชื่อคอร์ส</th>
			<th style="width:20%;text-align: center !important;color:black; !important;font-size:1em">รายละเอียด</th>
			<th style="width:20%;text-align: center !important;color:black; !important;font-size:1em">แก้ไข</th>
			<th style="width:20%;text-align: center !important;color:black; !important;font-size:1em">ลบ</th>
		</tr>
	</thead>
	<tbody style="color:black !important;">
	
		<?php while($resultCourse=mysql_fetch_array($queryCourse)){?>
		<tr>
			<td style="text-align: center !important;color:black; !important;font-size:1em"><?php echo $resultCourse["course_name"]?></td>
			<td style="text-align: center !important;color:black; !important;font-size:1em">
			<img class="popup_window pics" temp="<?php echo $resultCourse["course_id"]?>"  src="../pic/info.png" width="50" />
			</td>
			<td style="text-align: center !important;color:black; !important;font-size:1em">
			<img class="pics nav_link2" txt="แก้ไขข้อมูลคอร์ส" url="admin/insert_course_page.php?temp=<?php echo $resultCourse["course_id"] ?>" src="../pic/edit.png" width="50" />
			</td>
			<td style="text-align: center !important;color:black; !important;font-size:1em">
			<img class="pics"  src="../pic/delete.png" width="50"
			onClick="if(window.confirm('ต้องการลบกรุณายืนยัน'))
			{$('#mainscreen').load('admin/delete_page.php?temp=<?php echo $resultCourse["course_id"]."&role=3"?>');} " 
			/>
			</td>
		</tr>
		<?php }?>
	</tbody>
	
</table>
		  </div>
		</div>
	</div>
</div>
</div>

 
<div id="data-popup" class="popup">
    <div class="popup-body"><span class="popup-exit"></span>
 
        <div class="popup-content">
            <h2 class="popup-title">ข้อมูลคอร์ส</h2>
			<div class="popup-des">
			<img class="pics" src="../pic/bx_loader.gif" width="50" />
			</div>
        </div>
    </div>
</div>
<div class="popup-overlay"></div>
</form>
<script>
$(document).ready(function(){
$(".nav_link2").click(function(e){
				$("#h3title").html($(this).attr("txt"));
				$("#mainscreen").load($(this).attr("url"));
				return false;
			});
  	oTable = $('#Course').dataTable({
          "bJQueryUI": true,
          "sPaginationType": "full_numbers"
      });

$('.popup_window').click(function () {
        $('html').addClass('overlay');
        var activePopup = "#data-popup";
        $(activePopup).addClass('visible');
		 $('.popup-overlay').click(function () {
        clearPopup();
		});
		$.ajax({
		url:"admin/preview_course_data.php?temp="+$(this).attr("temp"),
			success:function(res){
			$(".popup-des").html(res);
			 $('.popup-exit').click(function () {
				clearPopup();
				});
			}
		});
 
    });
 
    $(document).keyup(function (e) {
        if (e.keyCode == 27 && $('html').hasClass('overlay')) {
            clearPopup();
        }
    });
 
      
 
});
	  
	
	 function clearPopup() {
        $('.popup.visible').addClass('transitioning').removeClass('visible');
        $('html').removeClass('overlay');
 
        setTimeout(function () {
            $('.popup').removeClass('transitioning');
        }, 200);
    }
</script>